package com.franklin.ideaplugin.api.ui.editor;

import com.franklin.ideaplugin.api.icon.ApiIcons;
import com.franklin.ideaplugin.api.ui.ToolBarWindowForm;
import com.franklin.ideaplugin.api.utils.SwingUtils;
import com.intellij.ui.components.JBScrollPane;
import lombok.Getter;

import javax.swing.*;
import java.awt.*;
import java.util.function.Consumer;

/**
 * @author Ye Junhui
 * @since 2023/7/12
 */
public class ConfirmCustomJsonEditor extends ToolBarWindowForm implements
        IBaseFormatJsonEditor ,
        IBaseSoftWrapEditor ,
        IBaseResetEditor
{
    private final JButton confirmButton = new JButton();
    private final JButton formatButton = new JButton();
    private final JButton resetButton = new JButton();
    private final JButton softWrapButton = new JButton();

    @Getter
    private final CustomEditor editor;

    public ConfirmCustomJsonEditor(CustomEditor customEditor) {
        this.editor = customEditor;
        this.addContent(this.editor,new Dimension(-1,-1));

        this.initFormatButton(this.editor,this.formatButton);
        this.confirmButton.setIcon(ApiIcons.SAVE_ICON);
        this.confirmButton.setText("Save content");
        this.confirmButton.setToolTipText("Save content");
        this.initRestButton(this.editor,this.resetButton);
        this.initSoftWrapButton(this.editor,this.softWrapButton);

        this.addToolButton(this.formatButton);
        this.addToolButton(this.confirmButton);
        this.addToolButton(this.resetButton);
        this.addToolButton(this.softWrapButton);
    }


    /**
     * 初始化确认按钮
     * @param confirmButtonHandler
     */
    public void initConfirmButton(Consumer<JButton> confirmButtonHandler){
        confirmButtonHandler.accept(this.confirmButton);
    }

}
